package com.jay.media.platform

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.KeyEvent

/**
 * @author xuzhou4
 * @date 2022/1/27
 */
const val TAG = "MediaButtonReceiver"

class MediaButtonReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        Log.d(TAG, "MediaButtonReceiver")
        val action = intent?.action ?: ""
        if (Intent.ACTION_MEDIA_BUTTON == action) {
            val keyEvent = intent?.getParcelableExtra<KeyEvent>(Intent.EXTRA_KEY_EVENT)
            Log.d(TAG, "$action keyCode = ${keyEvent?.keyCode}")
            when (keyEvent?.keyCode) {
                KeyEvent.KEYCODE_MEDIA_PREVIOUS -> {
                }
                KeyEvent.KEYCODE_MEDIA_NEXT -> {
                }
                KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE -> {
                }
                else -> {
                }
            }

        }
    }
}